import ajax from './index'

export interface Milkman {
  id: number,
  name: string,
  password: string,
  created_at: string,
  updated_at: string,
  phone: string,
  user_name: string
}

export interface milkmanMessageParam {
  id?: number
  name?: string,
  user_name?: string
}

export function getAllMilkman (): Promise<Milkman[]> {
  return ajax('/getAllMilkman')
}

export function setMilkmanMessage (param: milkmanMessageParam) {
  return ajax('/setMilkmanMessage', param, 'post')
}

export function addMilk (param: milkmanMessageParam) {
  return ajax('/addMilk', param, 'post')
}

export function removeMilkman (id: number) {
  return ajax('/removeMilkman', { id }, 'post')
}

export function resetPasswords (id: number) {
  return ajax('/resetPasswords', { id }, 'post')
}
